<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
[#include "/admin/include/head.htm"]
    <script type="text/javascript">
        $(function(){
            // 地区选择菜单
            $(".areaSelect").lSelect({
                url: "${base}/common/area.jhtml" // Json数据获取url
            });

            $("input[name=isChange]").change(function(){
                if($(this).val() == 'true'){
                    $('input[name=areaId]').removeAttr("disabled","disabled");
                    $('input[name=address]').removeAttr("disabled","disabled");
                    $(".area").show();
                }else{
                    $('input[name=areaId]').attr("disabled","disabled");
                    $('input[name=address]').attr("disabled","disabled");
                    $(".area").hide();
                }
            });


            $(".itemIds").click(function(){
                if($(this).attr("checked")){
                    $(this).closest("tr").children("td:last").find("input").removeAttr("disabled")
                }else{
                    $(this).closest("tr").children("td:last").find("input").attr("disabled","disabled")
                }
            });

            $("#all-items").click(function(){
                if($(this).attr("checked")){
                    $(".itemIds").each(function(){
                        $(this).attr("checked","true");
                        $(this).closest("tr").children("td:last").find("input").removeAttr("disabled")
                    });
                }else{
                    $(".itemIds").each(function(){
                        $(this).removeAttr("checked");
                        $(this).closest("tr").children("td:last").find("input").attr("disabled","disabled")
                    });
                }
            });
        });
    </script>
</head>
<body style="padding:10px;">
<div id="tabcontainer" style="margin:0; padding:0">
    <form action="${base}/admin/b2c/order/refund.jhtml" method="post" class="validate" id="mainform">
        <input type="hidden" name="orderId" value="${(order.id)!''}"/>
        <div class="table_title">
            <img src="${base}/resource/images/communication.gif">
            <span>基本信息</span>
        </div>
        <table class="inputTable2">
            <tr>
                <th>订单编号：</th>
                <td>${(order.orderNo)!}</td>
                <th>订单状态：</th>
                <td>${message("OrderStatus."+order.orderStatus)}</td>
                <th>订单总额：</th>
                <td>${currency(order.amount, true)}</td>

            </tr>
            <tr>
                <th>支付方式</th>
                <td>${order.paymentTypeName}</td>
                <th>发货状态：</th>
                <td>${message("ShipStatus."+order.shipStatus)}</td>
                <th>支付状态：</th>
                <td>${message("PayStatus."+order.payStatus)}</td>
            </tr>
            <tr>
                <th>会员帐号：</th>
                <td>${(order.member.username)!}</td>
                <th>手机号码：</th>
                <td>${(order.member.mobile)!}</td>
            </tr>
        </table>
        <div class="table_title">
            <img src="${base}/resource/images/communication.gif">
            <span>退款申请</span>
        </div>
        <table class="inputTable2">
            <tr>
                <th>服务类型：</th>
                <td>
                    [@u.radio name="isChange" list={'true': '换货', 'false':'退货'} value="true"/]
                </td>
            </tr>
            <tr>
                <th>联系人：</th>
                <td>
                    <input type="text" class="formText {required:true}" name="consignee" value="${order.consignee}">
                </td>
            </tr>
            <tr>
                <th>联系电话：</th>
                <td>
                    <input type="text" class="formText {required:true}" name="contact" value="${order.contact}">
                </td>
            </tr>
            <tr class="area">
                <th>收货人地区：</th>
                <td>
                    <input type="hidden" name="areaId" treePath="${(area.path)!}" class="input1 areaSelect {required: true}" value="${(area.id)!}" style="width:345px"/>
                </td>
            </tr>
            <tr class="area">
                <th>收货人地址：</th>
                <td>
                    <input type="text" name="address" value="${(order.address)!}" class="formText {required: true, maxlength: 250}" style="width:500px;"/>
                </td>
            </tr>
            <tr>
                <th>备注：</th>
                <td>
                    <textarea rows="5" cols="50" class="formText {required:true}" name="remark"></textarea>
                </td>
            </tr>
        </table>

        <div class="table_title">
            <img src="${base}/resource/images/communication.gif">
            <span>申请退款项</span>
        </div>
        <table class="inputTable" style="width:100%;">
            <tbody>
            <tr class="title">
                <th width="5%"><input id="all-items" type="checkbox"/></th>
                <th width="20%">商品编号</th>
                <th width="25%">商品名称</th>
                <th width="10%">购买数量</th>
                <th>退货数量</th>
            </tr>
            </tbody>
            [#assign canRefundCount = 0]
            [#list order.orderItems as orderItem]
                [#if !orderItem.refund?? || orderItem.refund.refundStatus = "refuse"]
                [#assign canRefundCount = canRefundCount + 1]
                <tr>
                    <td>
                        <input class="itemIds" type="checkbox" name="itemIds" value="${orderItem.id}" />
                    </td>
                    <td>
                        ${orderItem.productCode}
                    </td>
                    <td>${orderItem.productName}</td>
                    <td>${orderItem.quantity}</td>
                    <td>
                        <input type="text" disabled="disabled" name="quantitys" class="text" value="${orderItem.quantity}" min="1" max="${orderItem.quantity}"/>
                    </td>
                </tr>
                [/#if]
            [/#list]
            [#if canRefundCount = 0]
                <tr>
                    <td colspan="6" style="text-align: center">
                        无可退款项
                    </td>
                </tr>
            [/#if]
        </table>
    </form>
    <div class="table_title">
        <img src="${base}/resource/images/communication.gif">
        <span>已申请退款项</span>
    </div>
    <table class="inputTable" style="width:100%;">
        <tbody>
        <tr class="title">
            <th width="20%">商品编号</th>
            <th width="30%">商品名称</th>
            <th width="10%">购买数量</th>
            <th width="10%">退货数量</th>
            <th>退换货</th>
            <th>状态</th>
        </tr>
        </tbody>
    [#assign refundedCount = 0]
    [#list order.orderItems as orderItem]
        [#if orderItem.refund?? && orderItem.refund.refundStatus != "refuse"]
        [#assign refundedCount = refundedCount + 1]
        <tr>
            <td> ${orderItem.productCode} </td>
            <td> ${orderItem.productName} </td>
            <td> ${orderItem.quantity} </td>
            <td> ${orderItem.refund.quantity} </td>
            <td>
                [#if orderItem.refund.isChange]
                    换货
                [#else]
                    退货
                [/#if]
            </td>
            <td> ${message("RefundStatus."+orderItem.refund.refundStatus)} </td>
        </tr>
        [/#if]
    [/#list]
    [#if refundedCount = 0]
        <tr>
            <td colspan="6" style="text-align: center">
                无退款记录
            </td>
        </tr>
    [/#if]
    </table>

</div>
</body>
</html>